import fs from "fs";
import path from "path";
import { decryptUTF8 } from "siphan";
import { safeWrite } from "./utils";
function solve(cipher, cipherPath, outputName) {
    fs.readFile(path.resolve(process.cwd(), cipherPath), function (err, data) {
        if (err !== null) {
            throw err;
        }
        safeWrite(path.resolve(process.cwd(), outputName), decryptUTF8(data.toString(), cipher, function (e) { return console.log(e); }));
    });
}
export default function decryptMain(keyPath, cipherPath, outputName) {
    fs.readFile(path.resolve(process.cwd(), keyPath), function (err, data) {
        if (err !== null) {
            throw err;
        }
        solve(data.toString(), cipherPath, outputName);
    });
}
